# -*- encoding=utf8 -*-
"""
RedFlag-TC000016   	播放顺序
进入相册选择素材后进行排序操作
进入装饰页进行比对
"""
__author__ = "ldm"

import sys
import os
# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
from device_elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()

log("-----------------------------------------------唤起分类后切换视频检查全部分类列表-------------------------------------------------")
# # 获取手机品牌
# phone_model = shooter.get_phone_model()
# #判断调用方法
# if phone_model:
#     if "huawei" in phone_model.lower() or "华为" in phone_model:
#         # 调用本地相机拍摄一张照片
#         shooter.local_camera_takes_photos_hauweiP50()
#         # 调用相机拍摄一个7S的视频
#         shooter.local_camera_captures_videos_huaweiP50("60 fps", "4K", 7)
#     elif "vivo" in phone_model.lower():
#         shooter.local_camera_takes_photos_vivoS7()
#         shooter.set_and_capture_video_vivoS7(fps_show_60_vivo, size_show_4K_vivo, 7)
#     else:
#         print(f"不支持的手机品牌: {phone_model}")
# else:
#     print("无法获取手机型号信息，跳过拍摄操作")

# 进入ugc相册
shooter.enter_album()
# 点击视频列表
shooter.click_element(album_video_list)
#添加视频列表第六个视频
shooter.click_element(album_select_button[5])
# 点击照片列表
shooter.click_element(album_photo_list)
# 添加照片列表第一张照片
shooter.click_element(album_select_button1)
# 预览栏预览第二个素材(新增的照片)
shooter.click_element(preview_bar_elow[1].child("cn.migu.video.clip.walle:id/walle_ugc_clip_thumb_iv"))
# 进行截屏操作,将照片保存在当前目录下
screenshot_path = shooter.capture_screenshot("TC000016A.png")
# 点击返回关闭预览
shooter.click_element(return_button_in_preview)
# 通过坐标移动素材顺序
preview_bar_elow[1].drag_to(preview_bar_elow[0])
# 点击下一步
shooter.click_element(album_next_button)
# 等待元素出现
shooter.wait_for_element_appearance(decoration_page_return_button, 10)
# 断言
shooter.assert_image_exists(screenshot_path, "断言失败，图片比对排序有误", threshold=0.6)
#关闭应用
stop_app(UGC_package_name)